-- MiniMap
-- by eLe
-------------------------------------------------------------------------------
-- Description:
--
-- Adds things to the minimap.
--
-------------------------------------------------------------------------------
-- Support thread here:
--
-- http://forums.kleientertainment.com/showthread.php?11951
--
-------------------------------------------------------------------------------
--
-- To install this mod, put this file in a new folder under
-- "...\Steam\steamapps\common\dont_starve\mods" called "MiniMap",
-- then open the "modsettings.lua" file in the mods folder and add the
-- following but without the beginning "--":
--
--ModManager:AddMod("MiniMap")
--
-- When you run the game you should see a screen pop up that lists this mod as
-- being loaded.
--
-------------------------------------------------------------------------------
--
-- Changelog:
--
-- v0.9 Live Update.
--		Removed Marsh_tree as it was added in the Live update.
--		Changed beefaloherd, koalefant_summer, koalefant_winter, spiderqueen, insanityrock, mound to non-character icons.
--
-- v0.8 End Update.
--		Removed Houndmound as it was added in the End update.
--		Added Marsh_tree.
--
-- v0.7 Removed mermhouse, cookpot, farmplot, farmplot2, farmplot3, beebox, birdcage, nightlight, marblepillar.
--		Added krampus_sack with krampus_sack.png icon.
--		Changed rabbithole icon to shop.png.
--		Rabbit holes, mushrooms, walls, in/sanity rock, and teleportato items disabled by default.
--
-- v0.6 Condensed local functions as there are only a limited number of icons, and it doesn't make any sense to have a seperate function for things that share the same icons.
--
-- v0.5 Added chester_eyebone, sanityrock, carrot_planted, pigtorch.
--		Changed code to make it more readable.
--		Changed icons again; refer to minimap icons.txt for full list.
--
-- v0.4 Removed pighouse, as it is now included in vanilla.
--		Added red_mushroom, green_mushroom, blue_mushroom, insanityrock (obelisk), houndmound, marblepillar, mermhouse.
--		Changed icons around (such as food/plants now have the wheat icon).
--
-- v0.3 Added Heavenfall's teleportato code; edited for easier ability to disable if desired.
--		Added beebox, birdcage, nightlight, rabbithole, mandrake, beefaloherd, cookpot, spiderqueen, koalefant_summer, koalefant_winter, wall_stone,
--		wall_wood, wall_hay, farmplot, farmplot2, farmplot3, teleportato_ring, teleportato_box, teleportato_crank, teleportato_potato
--		Changed mound icon to Wilton.png
--
-- v0.2 Thanks to WrathOf for the better adding icons to the minimap thingy code.
--		Added grave mounds with temp icon until I can get the texture converter to work.
--
-- v0.1 Figured out how to add the pighouse to the minimap and get it to run in the mod system
-------------------------------------------------------------------------------

local function AddMiniMapIcon(inst, img, priority)
	if inst and not inst.MiniMapEntity then
		local minimap = inst.entity:AddMiniMapEntity()
		minimap:SetIcon( img )					-- png name found in data/minimap/minimap_data.tex
		minimap:SetPriority( priority or 1 )	-- 1-10
		--minimap:SetRenderOnTopOfMask( false )	-- true/false
	end
end

--Plants, Farms
local function plantPrefabPostInit(inst)
	if inst then AddMiniMapIcon(inst, "wheat.png", 5) end
end
--/Plants, Farms

--Animals
local function animalPrefabPostInit(inst)
	if inst then AddMiniMapIcon(inst, "shop.png", 5) end
end
--/Animals

--Monsters
local function monsterPrefabPostInit(inst)
	if inst then AddMiniMapIcon(inst, "cactus.png", 5) end
end
--/Monsters

--Walls, Pillar
local function wallPrefabPostInit(inst)
	if inst then AddMiniMapIcon(inst, "basalt.png", 5) end
end
--/Walls, Pillar

--Graves
local function moundPrefabPostInit(inst)
	if inst then AddMiniMapIcon(inst, "gravestones.png", 5) end
end
--/Graves

--Teleportato items
local function teleportatoPrefabPostInit(inst)
	if inst then AddMiniMapIcon(inst, "teleportato.png", 5) end
end
--/Teleportato items

--Other
local function treasurePrefabPostInit(inst)
	if inst then AddMiniMapIcon(inst, "treasure.png", 5) end
end

local function krampus_sackPrefabPostInit(inst)
	if inst then AddMiniMapIcon(inst, "krampus_sack.png", 5) end
end
--/Other

--Plants
AddPrefabPostInit( "carrot_planted", plantPrefabPostInit )
AddPrefabPostInit( "mandrake", plantPrefabPostInit )
--AddPrefabPostInit( "blue_mushroom", plantPrefabPostInit )
--AddPrefabPostInit( "green_mushroom", plantPrefabPostInit )
--AddPrefabPostInit( "red_mushroom", plantPrefabPostInit )
--/Plants

--Animals
AddPrefabPostInit( "beefaloherd", animalPrefabPostInit )
AddPrefabPostInit( "koalefant_summer", animalPrefabPostInit )
AddPrefabPostInit( "koalefant_winter", animalPrefabPostInit )
--AddPrefabPostInit( "rabbithole", animalPrefabPostInit )
--/Animals

--Monsters
AddPrefabPostInit( "spiderqueen", monsterPrefabPostInit )
--/Monsters

--Structures
--AddPrefabPostInit( "wall_hay", wallPrefabPostInit )
--AddPrefabPostInit( "wall_stone", wallPrefabPostInit )
--AddPrefabPostInit( "wall_wood", wallPrefabPostInit )
--/Structures

--Other
AddPrefabPostInit( "chester_eyebone", treasurePrefabPostInit )
--AddPrefabPostInit( "insanityrock", treasurePrefabPostInit )
--AddPrefabPostInit( "sanityrock", treasurePrefabPostInit )
--AddPrefabPostInit( "pigtorch", treasurePrefabPostInit )
AddPrefabPostInit( "krampus_sack", krampus_sackPrefabPostInit )
--/Other

--Graves
AddPrefabPostInit( "mound", moundPrefabPostInit )
--/Graves

--Teleportato items
--AddPrefabPostInit( "teleportato_ring", teleportatoPrefabPostInit )
--AddPrefabPostInit( "teleportato_box", teleportatoPrefabPostInit )
--AddPrefabPostInit( "teleportato_crank", teleportatoPrefabPostInit )
--AddPrefabPostInit( "teleportato_potato", teleportatoPrefabPostInit )
--/Teleportato items